<template>
	<view class="wrap">
		<uni-search-bar @confirm="search" :focus="true" placeholder="请输入要核保的车牌号"></uni-search-bar>
		
		<uni-card class="card-pub" :title="carInfo.name" :isShadow="true">
			<uni-row>
				<uni-col :span="24">
					订单号: {{policy.dingdbh}}
				</uni-col>
			</uni-row>
			<uni-row>
				<uni-col :span="24">
					车牌号: {{policy.bebxcph}}
				</uni-col>
			</uni-row>
			<uni-row>
				<uni-col :span="24">
					车辆名称: {{policy.chelmc}}
				</uni-col>
			</uni-row>
			<uni-row>
				<uni-col :span="24">
					被保险人: {{policy.beibxr}}
				</uni-col>
			</uni-row>
			<uni-row>
				<uni-col :span="24">
					被保险人电话: {{policy.beibxrlxdh}}
				</uni-col>
			</uni-row>
			
		</uni-card>
		
		<u-form :model="model" :rules="rules" ref="uForm">
			<uni-section class="pub-title" title="发动机" type="line"></uni-section>
			<u-form-item label="从上往下正面45°" prop="photo" label-width="250">
				<u-upload max-count="1" :action="action" :header="header" @on-success="onSuccess1"></u-upload>
			</u-form-item>
			<u-form-item label="从下往上正面45°" prop="photo" label-width="250">
				<u-upload max-count="1" :action="action" :header="header" @on-success="onSuccess2"></u-upload>
			</u-form-item>
			<u-form-item label="从左往右45°" prop="photo" label-width="250">
				<u-upload max-count="1" :action="action" :header="header" @on-success="onSuccess3"></u-upload>
			</u-form-item>
			<u-form-item label="从右往左45°" prop="photo" label-width="250">
				<u-upload max-count="1" :action="action" :header="header" @on-success="onSuccess4"></u-upload>
			</u-form-item>
			
			<uni-section class="pub-title" title="变速箱" type="line"></uni-section>
			<u-form-item label="从上往下45°" prop="photo" label-width="250">
				<u-upload max-count="1" :action="action" :header="header" @on-success="onSuccess5"></u-upload>
			</u-form-item>
			<u-form-item label="从下往上45°" prop="photo" label-width="250">
				<u-upload max-count="1" :action="action" :header="header" @on-success="onSuccess6"></u-upload>
			</u-form-item>
			
			<uni-section class="pub-title" title="底盘" type="line"></uni-section>
			<u-form-item label="左前悬架总成" prop="photo" label-width="250">
				<u-upload max-count="1" :action="action" :header="header" @on-success="onSuccess7"></u-upload>
			</u-form-item>
			<u-form-item label="右前悬架总成" prop="photo" label-width="250">
				<u-upload max-count="1" :action="action" :header="header" @on-success="onSuccess8"></u-upload>
			</u-form-item>
			<u-form-item label="左后悬架总成" prop="photo" label-width="250">
				<u-upload max-count="1" :action="action" :header="header" @on-success="onSuccess9"></u-upload>
			</u-form-item>
			<u-form-item label="右后悬架总成" prop="photo" label-width="250">
				<u-upload max-count="1" :action="action" :header="header" @on-success="onSuccess10"></u-upload>
			</u-form-item>
			
			<uni-section class="pub-title" title="车身外观" type="line"></uni-section>
			<u-form-item label="右前大灯45°" prop="photo" label-width="250">
				<u-upload
					:fileList="fileList"
					:maxCount="1"
				></u-upload>
			</u-form-item>
			<u-form-item label="左前大灯45°" prop="photo" label-width="250">
				<u-upload
					:fileList="fileList"
					:maxCount="1"
				></u-upload>
			</u-form-item>
			<u-form-item label="右后大灯45°" prop="photo" label-width="250">
				<u-upload
					:fileList="fileList"
					:maxCount="1"
				></u-upload>
			</u-form-item>
			<u-form-item label="左后大灯45°" prop="photo" label-width="250">
				<u-upload
					:fileList="fileList"
					:maxCount="1"
				></u-upload>
			</u-form-item>
			
			<uni-section class="pub-title" title="车身内饰" type="line"></uni-section>
			<u-form-item label="车身仪表盘" prop="photo" label-width="250">
				<u-upload
					:fileList="fileList"
					:maxCount="1"
				></u-upload>
			</u-form-item>
			<u-form-item label="车身仪表台" prop="photo" label-width="250">
				<u-upload
					:fileList="fileList"
					:maxCount="1"
				></u-upload>
			</u-form-item>
			<u-form-item label="前后座椅" prop="photo" label-width="250">
				<u-upload
					:fileList="fileList"
					:maxCount="1"
				></u-upload>
			</u-form-item>
			<u-form-item label="顶棚内饰" prop="photo" label-width="250">
				<u-upload
					:fileList="fileList"
					:maxCount="1"
				></u-upload>
			</u-form-item>
			<uni-section class="pub-title" title="车头" type="line"></uni-section>
			<u-form-item label="车辆正面，车牌号" prop="photo" label-width="250">
				<u-upload
					:fileList="fileList"
					:maxCount="1"
				></u-upload>
			</u-form-item>
			<uni-section class="pub-title" title="前挡风" type="line"></uni-section>
			<u-form-item label="车辆识别代码" prop="photo" label-width="250">
				<u-upload
					:fileList="fileList"
					:maxCount="1"
				></u-upload>
			</u-form-item>
		</u-form>
		<u-button @click="submit" type="primary">提交</u-button>
	</view>
</template>

<script>
export default {
	data() {
		let that = this;
		return {
			fadj_0: null,
			fadj_1: null,
			fadj_2: null,
			fadj_3: null,
			
			biansx_1: null,
			biansx_2: null,
			
			dip_1: null,
			dip_2: null,
			dip_3: null,
			dip_4: null,
			
			cheswg_1: null,
			cheswg_2: null,
			cheswg_3: null,
			cheswg_4: null,
			
			chesns_1: null,
			chesns_2: null,
			chesns_3: null,
			chesns_4: null,
			
			chet_1: null,
			
			qianfd_1: null,
			
			header: {
				"X-Access-Token": uni.getStorageSync("token")
			},
			action: getApp().globalData.serviceUrl + "/sys/common/upload",
			policy: {
				dingdbh: "",
				bebxcph: "",
				chelmc: "",
				beibxr: "",
				beibxrlxdh: ""
			},
			fileList: [],
			model: {
			},
			rules: {}
		};
	},
	methods: {
		onSuccess(resp) {
			if (resp.success)
				this.fadj_1 = resp.message
		},
		
		onSuccess2(resp) {
			if (resp.success)
				this.fadj_2 = resp.message
		},
		
		onSuccess3(resp) {
			if (resp.success)
				this.fadj_3 = resp.message
		},
		
		onSuccess4(resp) {
			if (resp.success)
				this.fadj_4 = resp.message
		},
		
		onSuccess5(resp) {
			if (resp.success)
				this.biansx_1 = resp.message
		},
		
		onSuccess6(resp) {
			if (resp.success)
				this.biansx_2 = resp.message
		},
		
		onSuccess7(resp) {
			if (resp.success)
				this.dip_1 = resp.message
		},
		
		onSuccess8(resp) {
			if (resp.success)
				this.dip_2 = resp.message
		},
		
		onSuccess9(resp) {
			if (resp.success)
				this.dip_3 = resp.message
		},
		
		onSuccess10(resp) {
			if (resp.success)
				this.dip_4 = resp.message
		},
		
		onSuccess11(resp) {
			if (resp.success)
				this.cheswg_1 = resp.message
		},
		
		onSuccess12(resp) {
			if (resp.success)
				this.cheswg_2 = resp.message
		},
		
		onSuccess13(resp) {
			if (resp.success)
				this.cheswg_3 = resp.message
		},
		
		onSuccess14(resp) {
			if (resp.success)
				this.cheswg_4 = resp.message
		},
		
		onSuccess15(resp) {
			if (resp.success)
				this.chesns_1 = resp.message
		},
		
		onSuccess16(resp) {
			if (resp.success)
				this.chesns_2 = resp.message
		},
		
		onSuccess17(resp) {
			if (resp.success)
				this.chesns_3 = resp.message
		},
		
		onSuccess18(resp) {
			if (resp.success)
				this.chesns_4 = resp.message
		},
		
		onSuccess19(resp) {
			if (resp.success)
				this.chet_1 = resp.message
		},
		
		onSuccess20(resp) {
			if (resp.success)
				this.qianfd_1 = resp.message
		},
		
		search(e) {
			console.log(e)
			uni.request({
				url: getApp().globalData.serviceUrl + "/order/kuybOrder/getOrderByCheph",
				data: {
					cheph: e.value
				},
				method: 'GET',
				header: {
					"X-Access-Token": uni.getStorageSync("token")
				},
				success: (resp) => {
					if (resp.data.success) {
						this.policy = resp.data.result
						
					} else {
						uni.showToast({
							title: resp.data.message,
							icon: 'none'
						});
					}
				}
			});
		},
		
		submit() {
			if(!this.policy.dingdbh) {
				uni.showToast({
					title: "先查询车辆信息再上传照片!",
					icon: 'none'
				});
				return
			}
			
			uni.request({
				url: getApp().globalData.serviceUrl + "/order/kuybOrder/yewyUploadHebzp",
				data: {
					dingdbh: this.policy.dingdbh,
					fadj_1: this.fadj_1,
					fadj_2: this.fadj_2,
					fadj_3: this.fadj_3,
					fadj_4: this.fadj_4,
					
					biansx_1: this.biansx_1,
					biansx_2: this.biansx_2,
					
					dip_1: this.dip_1,
					dip_2: this.dip_2,
					dip_3: this.dip_3,
					dip_4: this.dip_4,
					
					cheswg_1: this.cheswg_1,
					cheswg_2: this.cheswg_2,
					cheswg_3: this.cheswg_3,
					cheswg_4: this.cheswg_4,
					
					chesns_1: this.chesns_1,
					chesns_2: this.chesns_2,
					chesns_3: this.chesns_3,
					chesns_4: this.chesns_4,
					
					chet_1: this.chet_1,
					
					qianfd_1: this.qianfd_1			
				},
				method: 'PUT',
				header: {
					"X-Access-Token": uni.getStorageSync("token")
				},
				success: (resp) => {
					if (resp.data.success) {
						uni.showToast({
							title: "上传成功",
							icon: 'none'
						});
						
					} else {
						uni.showToast({
							title: resp.data.message,
							icon: 'none'
						});
					}
				}
			});
		}
	}
};
</script>

<style scoped lang="scss">
.wrap {
	padding: 20rpx;
}

</style>
